<template>
	<view class="content">
		<button class="size" @tap="addEventListener">添加按键事件监听器</button>
		<input type="text" placeholder="请输入"></input><br/>
		<button class="size" @tap="hideSoftKeybord">隐藏软键盘</button>
		<input type="email" placeholder="请输入" @focus="focus"></input>
		<button class="size" @tap="showSoftKeybord">显示软键盘</button>
		<button class="size" @tap="removeEventListener">移除按键事件监听器</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type:"nick"
			}
		},
		methods: {
			addEventListener() {
				// 点击监听器=> 点击返回按钮=> 返回结果
				plus.key.addEventListener("backbutton", function() {
					console.log("BackButton Key pressed!");
				});
			},
			hideSoftKeybord(){
				// 点击输入框=>键盘弹起=>点击隐藏键盘=>键盘隐藏
				plus.key.hideSoftKeybord();
			},
			focus(){
				plus.key.setAssistantType('email')
			},
			showSoftKeybord(){
				plus.key.showSoftKeybord();
			},
			removeEventListener(){
				plus.key.removeEventListener("backbutton",function(){
					console.log("移除回调")
				});
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.size {
		margin: 30rpx 0;
	}
</style>
